package cn.lanqiao.ui;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;

import cn.lanqiao.entity.User;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class HistoryFrm extends JFrame {
	
	private JPanel contentPane;
	private JTable table;
	private  static User user;
	public HistoryFrm(User user) {
		this.user = user;
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 985, 469);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(14, 97, 939, 312);
		contentPane.add(scrollPane);
		//初始化jtable
		table = new JTable();
		cn.lanqiao.service.HistoryService service = new cn.lanqiao.serviceimpl.HistoryServiceImpl();//创建业务层对象
		Object[][] datas = service.getHistory(user.getUserID());	//调用数据层方法返回一个二维数组
		String[] head = new String[] {"英雄","参团率","胜负","KDA","伤害","承伤","场次评价","评分"};
		table.setModel(new DefaultTableModel(datas,head));
		table.setEnabled(false);
		scrollPane.setViewportView(table);
		
		JLabel label = new JLabel("历史战绩");
		label.setFont(new Font("等线 Light", Font.BOLD, 30));
		label.setBounds(397, 33, 155, 32);
		contentPane.add(label);
		
		JButton btnback = new JButton("返回");
		btnback.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				UserFrm uf = new UserFrm(user);
				uf.setVisible(true);
				HistoryFrm.this.setVisible(false);
			}
		});
		btnback.setBackground(Color.WHITE);
		btnback.setBounds(0, 0, 113, 27);
		contentPane.add(btnback);

		//居中
		this.setLocationRelativeTo(null);
	}
}